package com.finger.eduservice.handler;

import com.finger.commonutils.R;
import com.finger.eduservice.exception.GuliException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R arithmeticException(Exception e) {
        e.printStackTrace();

        return R.error().message("执行了全局异常。。");
    }

    @ExceptionHandler(GuliException.class)
    @ResponseBody
    public R guliException(GuliException e) {
        e.printStackTrace();
        return R.error().message(e.getMsg());
    }
}
